#!/bin/bash

cp meta/linux/.config ../build/linux-5.3.7/
cp meta/busybox/.config ../build/busybox-1.32.1/

pushd ../build/linux-5.3.7/
make
popd

pushd ../build/busybox-1.32.1/
    make && make install
    mkdir ./initramfs/
    pushd ./initramfs/
        cp ../_install/* -rf ./
        mkdir dev proc sys
        mkdir -p lib/modules
        mkdir -p etc/init.d
        touch etc/init.d/rcS
        chmod a+x etc/init.d/rcS
        sudo cp -a /dev/{null,console,tty,tty1,tty2,tty3,tty4} dev/
        cp ../../linux-5.3.7/drivers/net/ethernet/intel/e1000/e1000.ko lib/modules
        rm linuxrc
        cp ../../../src/meta/linux/init ./
        chmod a+x init
        find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../initramfs.cpio.gz
    popd
popd

cp -Rv .vscode ../build/linux-5.3.7/
